<div class="layui-fluid" id="service-audit-consumer">
    <form class="layui-form" lay-filter="service-audit-consumer-form" id="service-audit-consumer-form" method="post"
          onsubmit="return false">
        <div class="layui-form-item febs-hide">
            <input type="text" name="serviceId" autocomplete="off" class="layui-input userServiceId">
            <input type="text" name="userServiceId" autocomplete="off" class="layui-input userServiceId">
            <input type="text" name="version" autocomplete="off" class="layui-input userServiceVersion">
            <input type="text" name="name" autocomplete="off" class="layui-input userServiceName">
            <input type="text" name="spName" autocomplete="off" class="layui-input userServiceSpName">
            <input type="text" name="ips" autocomplete="off" class="layui-input userServiceSpName">
            <input type="text" name="frequency" autocomplete="off" class="layui-input userServiceSpName">
            <input type="text" name="auditPerson" autocomplete="off" class="layui-input userServiceSpName">
            <input type="text" name="applyPerson" autocomplete="off" class="layui-input userServiceSpName">
        </div>

        <div class="layui-card-body layui-row layui-col-space10">
            <div class="layui-col-md6">
                <label class="layui-label layui-col-md3">申请人：</label> <span
                    class="userServiceApplyPerson"><!--admin--></span>
            </div>
            <div class="layui-col-md6">
                <label class="layui-label layui-col-md3">申请时间：</label> <span class="applyTime"><!--2018-03-03 22:22:33--></span>
            </div>
            <div class="layui-col-md6">
                <label class="layui-label layui-col-md3">调用服务IP：</label> <span
                    class="userServiceIps"><!--12.36.56.99--></span>
            </div>
            <div class="layui-col-md6">
                <label class="layui-label layui-col-md3">调用频率：</label> <span class="userServiceFrequency"><!--10000万次/天--></span>
            </div>

            <div class="layui-col-md6 layui-form-item">
                <input type="radio" name="applyStatus" value="2" title="同意" checked="">
                <input type="radio" name="applyStatus" value="3" title="不同意">
            </div>

            <div class="layui-col-md12 layui-form-item">
                <textarea name="opinion" placeholder="输入审核意见" class="layui-textarea opinion"></textarea>
            </div>
        </div>

        <div class="layui-form-item febs-hide">
            <button class="layui-btn" lay-submit="" lay-filter="service-audit-consumer-form-submit"
                    id="submit"></button>
            <button type="reset" class="layui-btn" id="reset"></button>
        </div>

    </form>
</div>

<script>
    //  https://www.open-open.com/code/view/1430625516632
    layui.use(['febs', 'form'], function () {
        var $ = layui.$,
            febs = layui.febs,
            form = layui.form,
            pop_data = POPUP_DATA,
            $view = $('#service-audit-consumer'),
            formRepeat = false;// 表单重复提交 出此下策 shit!!
        form.render();
        initValue();

        function initValue() {
            pop_data.auditInfo.opinion = pop_data.auditInfo.userServiceOpinion;
            $view.find('.userServiceApplyPerson').text(pop_data.auditInfo.userServiceApplyPerson);
            $view.find('.applyTime').text(pop_data.auditInfo.applyTime);
            $view.find('.userServiceIps').text(pop_data.auditInfo.userServiceIps);
            $view.find('.opinion').val(pop_data.auditInfo.userServiceOpinion);

            $view.find('.userServiceFrequency').text(pop_data.auditInfo.userServiceFrequency);
            form.val("service-audit-consumer-form", {
                "auditPerson": currentUser.username,
                "applyPerson": pop_data.auditInfo.userServiceApplyPerson,
                "serviceId": pop_data.auditInfo.serviceId,
                "userServiceId": pop_data.auditInfo.userServiceId,
                "version": pop_data.auditInfo.version,
                "name": pop_data.auditInfo.name,
                "spName": pop_data.auditInfo.spName,
                "opinion": pop_data.auditInfo.userServiceOpinion,
                "ips": pop_data.auditInfo.userServiceIps,
                "frequency": pop_data.auditInfo.userServiceFrequency,
                "applyStatus": pop_data.auditInfo.applyStatus
            });
        }

        /* 监听提交 */
        form.on('submit(service-audit-consumer-form-submit)', function (data) {

            if (febs.nativeEqual(data.field, pop_data.auditInfo)) {
                febs.alert.warn('数据未作任何修改！');
                return false;
            }

            if (formRepeat) {
                formRepeat = false;
                return false;
            } else {
                formRepeat = true;
                febs.post(ctx + 'userService/update', data.field, function () {
                    layer.closeAll();
                    febs.alert.success('审核成功');
                    $('#febs-service-audit-info').find('#audit-consumer-query').click();
                });
            }
            return false;
        });
    });
</script>